
import { getCardAndPackageList } from '../../../utils/networkRequest.js'
import { errorMsg } from '../../../utils/tool.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    packagelist: [
      { img: 'http://www.haoche666.com/storage/app_pics/images/list_package_card.png', serial: 'A', icon: 'http://www.haoche666.com/storage/app_pics/images/white_logo.png' },
      { img: 'http://www.haoche666.com/storage/app_pics/images/list_package_card.png', serial: 'B', icon: 'http://www.haoche666.com/storage/app_pics/images/white_logo.png' }
    ],
    topup: [
      { img: 'http://www.haoche666.com/storage/app_pics/images/list_cash_card.png', }
    ],
    cardAndPackageList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  onShow: function () { 
    let self = this;
    getCardAndPackageList((r) => {
      if (r.code == 0) {
        self.setData({
          cardAndPackageList: r.data
        })
      } else {
        errorMsg(r.message)
      }
    })
  },
  //点击项目编辑
  onItemEdit: function (e) {
    wx.navigateTo({
      url: '../addpackage/addpackage?isEdit=true&tagindex=0&item=' + JSON.stringify(e.currentTarget.dataset.item),
    })
  },
 //点击项目充值卡
  onCardItemEdit:function(e){ 
    wx.navigateTo({
      url: '../addpackage/addpackage?isEdit=true&tagindex=1&item=' + JSON.stringify(e.currentTarget.dataset.item),
    })
  },
 
  //跳转至添加新增套餐页面 
  addPackage:function(){
    wx.navigateTo({
      url: '../addpackage/addpackage'
    })
  }
})